package com.ldc.commonres.uts

import android.content.Context
import androidx.recyclerview.widget.RecyclerView
import com.google.android.flexbox.FlexDirection
import com.google.android.flexbox.FlexboxLayoutManager
import com.google.android.flexbox.JustifyContent
import com.ldc.commonres.common.BaseTagListAdapter
import com.ldc.commonres.model.BaseTagModel

object TagUts {

    fun tagList(list: List<BaseTagModel>, rv: RecyclerView) {
        val adapter = BaseTagListAdapter()
        adapter.newData(list)
        rv.let {
            it.adapter = adapter
            it.setHasFixedSize(true)
            it.layoutManager = getLayoutManager(it.context)
        }
    }

      fun getLayoutManager(context: Context): FlexboxLayoutManager =
        FlexboxLayoutManager(context).also {
            it.flexDirection = FlexDirection.ROW
            it.justifyContent = JustifyContent.FLEX_START
        }
}